This patch is to use GFW ACPI_OSI to identify guest OS type.
When ACPI_OSI gets OS type, it writes to a reserved port a
special val. then XEN can know the guest OS type.
NB. Linux returns true both for _OSI(linux) and _OSI(windows)
Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
Signed-off-by: Anthony Xu <anthony.xu@intel.com>
#define TO_LEGACY_IO(pa) (((pa)>>12<<2)|((pa)&0x3))
+const char * guest_os_name[] = {
+ "Unknown",
+ "Windows 2003 server",
+ "Linux",
+};
+
+static inline void set_os_type(VCPU *v, u64 type)
+{
+ if (type > OS_BASE && type < OS_END) {
+ v->domain->arch.vmx_platform.gos_type = type;
+ gdprintk(XENLOG_INFO, "Guest OS : %s\n", guest_os_name[type - OS_BASE]);
+ }
+}
+
+
static void legacy_io_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir)
{
struct vcpu *v = current;
p->df = 0;
p->io_count++;
+
+ if (dir == IOREQ_WRITE && p->addr == OS_TYPE_PORT) {
+ set_os_type(v, *val);
+ return;
+ }
if (vmx_ide_pio_intercept(p, val))
return;
v->arch.privregs = (mapped_regs_t *)vpd;
vcpu_share_privregs_with_guest(v);
vpd->vpd_low.virt_env_vaddr = vm_buffer;
-
+
+ v->domain->arch.vmx_platform.gos_type = OS_UNKNOWN;
/* Per-domain vTLB and vhpt implementation. Now vmx domain will stick
* to this solution. Maybe it can be deferred until we know created
* one as vmx domain */
#include <public/xen.h>
#include <public/hvm/params.h>
#include <asm/viosapic.h>
+
+
+/* Value of guest os type */
+#define OS_BASE 0xB0
+#define OS_UNKNOWN 0xB0
+#define OS_WINDOWS 0xB1
+#define OS_LINUX 0xB2
+#define OS_END 0xB3
+
+/* port guest Firmware use to indicate os type
+ * this port is used to trigger SMI on x86,
+ * it is not used on ia64 */
+#define OS_TYPE_PORT 0xB2
+
struct mmio_list;
typedef struct virtual_platform_def {
+ unsigned long gos_type;
unsigned long buffered_io_va;
spinlock_t buffered_io_lock;
unsigned long buffered_pio_va;